﻿using Com.JunCaiSoft.DBContext;
using Com.JunCaiSoft.Hr.Dao;
using Com.JunCaiSoft.Hr.IDao;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Com.JunCaiSoft.Hr
{
    public static class HrServiceCollectionExtension
    {
        public static IServiceCollection AddHr(this IServiceCollection services)
        {

            //添加公司相关注入
            services.TryAddSingleton<ICompanyDao>(new CompanyDao(services.BuildServiceProvider().GetService<MSSQLDbContext>()));
            //添加部门相关注入
            services.TryAddSingleton<IPartmentDao>(new PartmentDao(services.BuildServiceProvider().GetService<MSSQLDbContext>()));
            //添加雇员相关注入
            services.TryAddSingleton<IEmployeeDao>(new EmployeeDao(services.BuildServiceProvider().GetService<MSSQLDbContext>()));

            return services;
        }
    }
}
